﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GameBase
{
    public class MutiSpriteObject : VisibleGameEntity
    {
        protected List<Sprite> listSprites = new List<Sprite>();
        private const float D_DEPTH = 0.0000001f;

        public List<Sprite> ListSprites
        {
            get { return listSprites; }
            set { listSprites = value; }
        }
        
        public void AddSprite(Sprite spite)
        {
            listSprites.Add(spite);
        }
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            base.Update(gameTime);
            foreach (Sprite sprite in listSprites)
            {
                sprite.Update(gameTime);
            }
        }

        public override void Draw(Microsoft.Xna.Framework.GameTime gameTime, Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
        {
            base.Draw(gameTime, spriteBatch);
            float d = Depth;
            foreach (Sprite sprite in listSprites)
            {
                if (d < 0.1)
                {
                    d = 0.1f;
                }
                sprite.Draw(gameTime, spriteBatch,
                    GetDrawPosition(), GetDrawRotate(), GetDrawScale(), d);
                d -= D_DEPTH;
            }
                
        }
    }
}
